import ky from "ky";

export async function profile(): Promise<Me> {
  return ky.get("/apis/auth/profile").json();
}

type LoginPayload = {
  username: string;
  password: string;
};

// TODO: error handling
export async function login({ username, password }: LoginPayload): Promise<Me> {
  return ky.post("/apis/auth/login", { json: { username, password } }).json();
}

export async function logout() {
  await ky.post("/apis/auth/logout");
}
